package com.example.demo.mapper;

import com.example.demo.dto.SearchInfo;
import com.example.demo.entity.Rukusunhuai;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository()
public interface Rukusunhuai_Mapper extends BaseMapper<Rukusunhuai>{
	
	@Select("SELECT Rukusunhuai.* ,cangku.chanpinname shangpinname"
	        + " FROM Rukusunhuai join cangku on Rukusunhuai.shangpinid=cangku.id ${where} ${limitstr}")
	public List<Rukusunhuai> select(SearchInfo info);
	
	@Select("SELECT COUNT(1) FROM Rukusunhuai" +
			" join cangku on Rukusunhuai.shangpinid=cangku.id ${where}")
	public long selectCount(SearchInfo info);
	
	@Insert("INSERT INTO Rukusunhuai (rukujiluid,shangpinid, number,time) VALUES (#{rukujiluid}, #{shangpinid}, #{number},#{time})")
	public void insert(Rukusunhuai Rukusunhuai);
	
	@Update("UPDATE Rukusunhuai SET rukujiluid = #{rukujiluid}, shangpinid = #{shangpinid}, "
	        + " number = #{number} WHERE id = #{id}")
	public void update(Rukusunhuai Rukusunhuai);
	
	
	@Delete("DELETE FROM Rukusunhuai WHERE id = #{id}")
	public void delete(int id);
	
	@Select("SELECT * FROM Rukusunhuai WHERE id = #{id}")
	public Rukusunhuai selectById(int id);
	
}
